package com.wenmingliang.demo2;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorTest {


    @Test
    public void test1() {
        Collection coll = new ArrayList();
        coll.add(123);
        coll.add(456);
        coll.add(new String("Tome"));
        coll.add(false);
        coll.add(new Person("Jerry",20));


        Iterator iterator = coll.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println("*******************************");
        for (Object o  : coll) {
            System.out.println(o);
        }
    }

    @Test
    public void test2() {
        int[] ints = {1, 2, 3, 4, 5, 6};
        for (Object                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 i : ints) {
            System.out.println(i);
        }
    }
}
